package com.pin.zheng.xingmulibrary.view;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.pin.zheng.xingmulibrary.R;
import com.pin.zheng.xingmulibrary.util.OnMultiClickListener;

import static com.pin.zheng.xingmulibrary.util.NetWordUtil.isNetSystemUsable;


public class CommomNoDialog extends Dialog {
    private Context mContext;
    private String content;
    private String title;
    private int image_r;
    private ImageView image;
    private ImageView image_wifi;

    public CommomNoDialog(Context context, int themeResId, String content) {
        super(context, themeResId);
        this.mContext = context;
        this.content = content;
    }

    public CommomNoDialog(Context context, int themeResId, String content, int image_r) {
        super(context, themeResId);
        this.mContext = context;
        this.content = content;
        this.image_r = image_r;
    }

    public CommomNoDialog setTitle(String title) {
        this.title = title;
        return this;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_commom_no);
        setCanceledOnTouchOutside(false);
        getWindow().setLayout(RelativeLayout.LayoutParams.MATCH_PARENT,
                RelativeLayout.LayoutParams.MATCH_PARENT);
        initView();

    }

    private void initView() {
        image = findViewById(R.id.image);
        if (image_r != 0) {
            image.setImageResource(image_r);
        }
        image_wifi = findViewById(R.id.image_wifi);
        if (isNetSystemUsable(mContext)) {
            image_wifi.setImageResource(R.drawable.icon_wifi_yes);
        } else {
            image_wifi.setImageResource(R.drawable.icon_wifi_no);
        }

        image_wifi.setOnClickListener(new OnMultiClickListener() {
            @Override
            public void onMultiClick(View v) {
                mContext.sendBroadcast(new Intent("com.outform.unhidebar"));
                Intent intent = new Intent();
                intent.setAction("com.android.navigation.status");
                intent.putExtra("hide", false);
                mContext.sendBroadcast(intent);
                mContext.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
            }
        });
    }


}
